home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992…tember: A ROM With a View / devSep92 / devSep92.dmg / Tools & Apps / Graphics & Imaging / SLUDGE 2.0 / Source Code / State_Storage_Manager.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-14  |  50.1 KB  |  901 lines  |  [TEXT/MPS ]

  1. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  2.   •                                                                           •
  3.   •   File Name:    State_Storage_Manager.c                                   •
  4.   •   ----------                                                              •
  5.   •                                                                           •
  6.   •   Copyright © 1990 Apple Computer, Inc.  All Rights Reserved              •
  7.   •                                                                           •
  8.   •       Description                                                         •
  9.   •       -----------                                                         •
  10.   •       This file contains the access routines to the state_storage record  •
  11.   •          of the SLUDGE cdev.  This record contains the current state (values)•
  12.   •          of the SLUDGE cdev.  It is saved as a resource of the cdev file     •
  13.   •          when SLUDGE is not active.                                          •
  14.   •                                                                           •
  15.   •       History                                                             •
  16.   •       -------                                                             •
  17.   •                                                                           •
  18.   •       Author          Date            Description                         •
  19.   •       ------------------------------------------------------------------  •
  20.   •       Kevin McEntee   2/20/90         Original Implementation             •
  21.   •                                                                           •
  22.   •                                                                           •
  23.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  24.  
  25. #include "State_Storage_Manager.h"
  26. #include <Dialogs.h>
  27. #include <Resources.h>
  28. #include <Memory.h>
  29. #include <Errors.h>
  30. #include <Devices.h>
  31. #include <Packages.h>
  32.  
  33.  
  34.  
  35.  
  36. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  37.   •                                                                           •
  38.   •   Function Name:   Set_State_Storage_Recommended_CDEV_Return_Value        •
  39.   •   --------------                                                          •
  40.   •                                                                           •
  41.   •       Description                                                         •
  42.   •       -----------                                                         •
  43.   •            This function sets the resource error condition true.              •
  44.   •                                                                           •
  45.   •                                                                           •
  46.   •       History                                                             •
  47.   •       -------                                                             •
  48.   •                                                                           •
  49.   •       Author          Date            Description                         •
  50.   •       ------------------------------------------------------------------  •
  51.   •       Kevin McEntee   7/25/89         Original Implementation             •
  52.   •                                                                           •
  53.   •                                                                           •
  54.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  55. void    Set_State_Storage_Recommended_CDEV_Return_Value(Handle cdevStorage, long value)
  56. {
  57.     HLock(cdevStorage);
  58.     ((State_Storage_Pointer) *cdevStorage)->State_Storage_Recommended_CDEV_Return_Value = value;
  59.     HUnlock(cdevStorage);
  60.     
  61. }
  62.  
  63. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  64.   •                                                                           •
  65.   •   Function Name:   Set_Resource_Error_Condition                           •
  66.   •   --------------                                                          •
  67.   •                                                                           •
  68.   •       Description                                                         •
  69.   •       -----------                                                         •
  70.   •            This function sets the resource error condition true.              •
  71.   •                                                                           •
  72.   •                                                                           •
  73.   •       History                                                             •
  74.   •       -------                                                             •
  75.   •                                                                           •
  76.   •       Author          Date            Description                         •
  77.   •       ------------------------------------------------------------------  •
  78.   •       Kevin McEntee   7/25/89         Original Implementation             •
  79.   •                                                                           •
  80.   •                                                                           •
  81.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  82. void    Set_Resource_Error_Condition(Handle cdevStorage)
  83. {
  84.     HLock(cdevStorage);
  85.     ((State_Storage_Pointer) *cdevStorage)->Allocated_State = false;
  86.     ((State_Storage_Pointer) *cdevStorage)->Resource_Error_State = true;
  87.     HUnlock(cdevStorage);
  88.     
  89. }
  90.  
  91. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  92.   •                                                                           •
  93.   •   Function Name:         Write_State_Resource                             •
  94.   •   --------------                                                          •
  95.   •                                                                           •
  96.   •       Description                                                         •
  97.   •       -----------                                                         •
  98.   •       This command writes the current contents of the state storage to       •
  99.   •          the state storage resource.  This command should be called by every •
  100.   •       routine (except Set_Resource_Error_Condition) that changes the state•
  101.   •          storage data.                                                          •
  102.   •                                                                           •
  103.   •       History                                                             •
  104.   •       -------                                                             •
  105.   •                                                                           •
  106.   •       Author          Date            Description                         •
  107.   •       ------------------------------------------------------------------  •
  108.   •       Kevin McEntee   7/25/89         Original Implementation             •
  109.   •                                                                           •
  110.   •                                                                           •
  111.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  112. void Write_State_Resource(Handle cdevStorage)
  113. {
  114.     short res_error;
  115.     short junk;
  116.     
  117.     HLock(cdevStorage);
  118.     ChangedResource( cdevStorage);
  119.         
  120.     res_error = ResError();
  121.     
  122.                                          /*••••••••••••••••••••••••••••••••••••••••••
  123.                                            •                                        •
  124.                                            •    If the resource can not be changed    •
  125.                                            •    then put up the proper alert, set     •
  126.                                            •    stae manager error condition, and    •
  127.                                            •    recommend a CDEV return value.        •
  128.                                            •                                        •
  129.                                            ••••••••••••••••••••••••••••••••••••••••••*/
  130.     if (res_error != noErr)
  131.         {
  132.         junk = StopAlert(1,nil);
  133.         Set_Resource_Error_Condition(cdevStorage);
  134.         Set_State_Storage_Recommended_CDEV_Return_Value(cdevStorage,cdevGenErr);
  135.         }
  136.  
  137.     WriteResource(cdevStorage);
  138.     HUnlock(cdevStorage);
  139.  
  140. }
  141. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  142.   •                                                                           •
  143.   •   Function Name:   Set_Allocated_Condition                                •
  144.   •   --------------                                                          •
  145.   •                                                                           •
  146.   •       Description                                                         •
  147.   •       -----------                                                         •
  148.   •            This function sets the allocated condition true.                   •
  149.   •                                                                           •
  150.   •                                                                           •
  151.   •       History                                                             •
  152.   •       -------                                                             •
  153.   •                                                                           •
  154.   •       Author          Date            Description                         •
  155.   •       ------------------------------------------------------------------  •
  156.   •       Kevin McEntee   7/25/89         Original Implementation             •
  157.   •                                                                           •
  158.   •                                                                           •
  159.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  160. void    Set_Allocated_Condition(Handle cdevStorage)
  161. {
  162.     HLock(cdevStorage);
  163.     ((State_Storage_Pointer) *cdevStorage)->Allocated_State = true;
  164.     ((State_Storage_Pointer) *cdevStorage)->Resource_Error_State = false;
  165.     HUnlock(cdevStorage);
  166.     
  167.     Write_State_Resource(cdevStorage);
  168. }
  169.  
  170.                                          /*••••••••••••••••••••••••••••••••••••••••••
  171.                                            •                                        •
  172.                                            •  On/Off button manager state routines    •
  173.                                            •                                        •
  174.                                            ••••••••••••••••••••••••••••••••••••••••••*/
  175. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  176.   •                                                                           •
  177.   •   Function Name:   Set_On_Off_Error_Condition                             •
  178.   •   --------------                                                          •
  179.   •                                                                           •
  180.   •       Description                                                         •
  181.   •       -----------                                                         •
  182.   •            This function sets the On/Off button error condition to the       •
  183.   •            passed Boolean value.                                              •
  184.   •                                                                           •
  185.   •                                                                           •
  186.   •       History                                                             •
  187.   •       -------                                                             •
  188.   •                                                                           •
  189.   •       Author          Date            Description                         •
  190.   •       ------------------------------------------------------------------  •
  191.   •       Kevin McEntee   7/20/89         Original Implementation             •
  192.   •                                                                           •
  193.   •                                                                           •
  194.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  195. void    Set_On_Off_Error_Condition(Handle cdevStorage, Boolean value)
  196. {
  197.     HLock(cdevStorage);
  198.     ((State_Storage_Pointer) *cdevStorage)->On_Off_Error_Condition = value;
  199.     HUnlock(cdevStorage);
  200.     
  201.     Write_State_Resource(cdevStorage);
  202. }
  203.  
  204.  
  205. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  206.   •                                                                           •
  207.   •   Function Name:    Get_On_Off_Error_Condition                              •
  208.   •   --------------                                                          •
  209.   •                                                                           •
  210.   •       Description                                                         •
  211.   •       -----------                                                         •
  212.   •       This query returns the On/Off button error condition.                  •
  213.   •                                                                           •
  214.   •       History                                                             •
  215.   •       -------                                                             •
  216.   •                                                                           •
  217.   •       Author          Date            Description                         •
  218.   •       ------------------------------------------------------------------  •
  219.   •       Kevin McEntee   7/20/89         Original Implementation             •
  220.   •                                                                           •
  221.   •                                                                           •
  222.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  223. Boolean Get_On_Off_Error_Condition(Handle cdevStorage)
  224. {
  225.     Boolean rvalue;
  226.     
  227.     HLock(cdevStorage);
  228.     rvalue = ((State_Storage_Pointer) *cdevStorage)->On_Off_Error_Condition;
  229.     HUnlock(cdevStorage);
  230.  
  231.     return(rvalue);
  232. }
  233.  
  234. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  235.   •                                                                           •
  236.   •   Function Name:    Set_On_Off_Recommended_CDEV_Return_Value              •
  237.   •   --------------                                                          •
  238.   •                                                                           •
  239.   •       Description                                                         •
  240.   •       -----------                                                         •
  241.   •       This command sets the On/Off button's recommended CDEV return value •
  242.   •          to the passed value.                                                  •
  243.   •                                                                           •
  244.   •       History                                                             •
  245.   •       -------                                                             •
  246.   •                                                                           •
  247.   •       Author          Date            Description                         •
  248.   •       ------------------------------------------------------------------  •
  249.   •       Kevin McEntee   7/20/89         Original Implementation             •
  250.   •                                                                           •
  251.   •                                                                           •
  252.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  253. void  Set_On_Off_Recommended_CDEV_Return_Value(Handle cdevStorage, long value)
  254. {
  255.     HLock(cdevStorage);
  256.     ((State_Storage_Pointer) *cdevStorage)->On_Off_Recommended_CDEV_Return_Value = value;
  257.     HUnlock(cdevStorage);
  258.     
  259.     Write_State_Resource(cdevStorage);
  260. }
  261.  
  262.  
  263. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  264.   •                                                                           •
  265.   •   Function Name:      Get_On_Off_Recommended_CDEV_Return_Value            •
  266.   •   --------------                                                          •
  267.   •                                                                           •
  268.   •       Description                                                         •
  269.   •       -----------                                                         •
  270.   •       This query returns the On/Off button's recommended CDEV return       •
  271.   •          value.                                                              •
  272.   •                                                                           •
  273.   •       History                                                             •
  274.   •       -------                                                             •
  275.   •                                                                           •
  276.   •       Author          Date            Description                         •
  277.   •       ------------------------------------------------------------------  •
  278.   •       Kevin McEntee   7/20/89         Original Implementation             •
  279.   •                                                                           •
  280.   •                                                                           •
  281.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  282. long Get_On_Off_Recommended_CDEV_Return_Value(Handle cdevStorage)
  283. {
  284.     short rvalue;
  285.     
  286.     HLock(cdevStorage);
  287.     rvalue = ((State_Storage_Pointer) *cdevStorage)->On_Off_Recommended_CDEV_Return_Value;
  288.     HUnlock(cdevStorage);
  289.  
  290.     return(rvalue);
  291. }
  292.  
  293. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  294.   •                                                                           •
  295.   •   Function Name:   SetUp_State_Storage                                     •
  296.   •   --------------                                                          •
  297.   •                                                                           •
  298.   •       Description                                                         •
  299.   •       -----------                                                         •
  300.   •       This command allocates the CDEV storage in the passed Handle.       •
  301.   •                                                                              •
  302.   •          If there is enough memory available for the allocation then         •
  303.   •       Allocated is the resulting state, otherwise the resulting state       •
  304.   •       is Nil Storage.                                                      •
  305.   •                                                                           •
  306.   •                                                                           •
  307.   •       History                                                             •
  308.   •       -------                                                             •
  309.   •                                                                           •
  310.   •       Author          Date            Description                         •
  311.   •       ------------------------------------------------------------------  •
  312.   •       Kevin McEntee   7/20/89         Original Implementation             •
  313.   •                                                                           •
  314.   •                                                                           •
  315.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  316. void SetUp_State_Storage(Handle *cdevStorage)
  317. {
  318.     
  319.     if (Count1Resources('SRES') != 0)
  320.          *cdevStorage = Get1Resource('SRES', 0);
  321.     else
  322.         {
  323.         *cdevStorage = NewHandle(sizeof(State_Storage_Record));
  324.         if (MemError() != noErr)
  325.             *cdevStorage = nil;
  326.         else
  327.             {
  328.             HLock(*cdevStorage);
  329.             
  330.             ((State_Storage_Pointer) **cdevStorage)->Sludge_Factor = 0;
  331.             
  332.             AddResource(*cdevStorage, 'SRES', 0, "\015State Storage");
  333.             if (ResError() != noErr)
  334.                 DebugStr("\022AddResource failed");
  335.                 
  336.             
  337.             Write_State_Resource(*cdevStorage);
  338.             HUnlock(*cdevStorage);
  339.  
  340.             Set_Allocated_Condition(*cdevStorage);
  341.             
  342.             
  343.             Set_ONFF_Value(*cdevStorage, false);
  344.             
  345.             }
  346.         }
  347. }
  348.  
  349.  
  350. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  351.   •                                                                           •
  352.   •   Function Name:      State_Storage_Allocated                              •
  353.   •   --------------                                                          •
  354.   •                                                                           •
  355.   •       Description                                                         •
  356.   •       -----------                                                         •
  357.   •       This query returns true if the storage in the passed Handle is in   •
  358.   •       the Allocated state or false if it is in the Nil Storage state.     •
  359.   •                                                                           •
  360.   •       History                                                             •
  361.   •       -------                                                             •
  362.   •                                                                           •
  363.   •       Author          Date            Description                         •
  364.   •       ------------------------------------------------------------------  •
  365.   •       Kevin McEntee   7/20/89         Original Implementation             •
  366.   •                                                                           •
  367.   •                                                                           •
  368.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  369. Boolean State_Storage_Allocated(Handle cdevStorage)
  370. {
  371.     Boolean        rvalue;
  372.     
  373.     HLock(cdevStorage);
  374.     rvalue = ((State_Storage_Pointer) *cdevStorage)->Allocated_State;
  375.     HUnlock(cdevStorage);
  376.     
  377.     return(rvalue);
  378. }
  379.  
  380. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  381.   •                                                                           •
  382.   •   Function Name:      State_Storage_Nil                                   •
  383.   •   --------------                                                          •
  384.   •                                                                           •
  385.   •       Description                                                         •
  386.   •       -----------                                                         •
  387.   •       This query returns true if and only if the storage in the passed       •
  388.   •          Handle is in the Nil storage state.                                  •
  389.   •                                                                           •
  390.   •       History                                                             •
  391.   •       -------                                                             •
  392.   •                                                                           •
  393.   •       Author          Date            Description                         •
  394.   •       ------------------------------------------------------------------  •
  395.   •       Kevin McEntee   7/25/89         Original Implementation             •
  396.   •                                                                           •
  397.   •                                                                           •
  398.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  399. Boolean State_Storage_Nil(Handle cdevStorage)
  400. {
  401.     return(cdevStorage == nil);
  402. }
  403.  
  404. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  405.   •                                                                           •
  406.   •   Function Name:      State_Storage_Resource_Error                        •
  407.   •   --------------                                                          •
  408.   •                                                                           •
  409.   •       Description                                                         •
  410.   •       -----------                                                         •
  411.   •       This query returns true if and only if the storage in the passed       •
  412.   •          Handle is in the resource error storage state.                      •
  413.   •                                                                           •
  414.   •       History                                                             •
  415.   •       -------                                                             •
  416.   •                                                                           •
  417.   •       Author          Date            Description                         •
  418.   •       ------------------------------------------------------------------  •
  419.   •       Kevin McEntee   7/25/89         Original Implementation             •
  420.   •                                                                           •
  421.   •                                                                           •
  422.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  423. Boolean State_Storage_Resource_Error(Handle cdevStorage)
  424. {
  425.     Boolean        rvalue;
  426.     
  427.     HLock(cdevStorage);
  428.     rvalue = ((State_Storage_Pointer) *cdevStorage)->Resource_Error_State;
  429.     HUnlock(cdevStorage);
  430.     
  431.     return(rvalue);
  432. }
  433.  
  434.  
  435. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  436.   •                                                                           •
  437.   •   Function Name:      Get_State_Storage_Recommended_CDEV_Return_Value     •
  438.   •   --------------                                                          •
  439.   •                                                                           •
  440.   •       Description                                                         •
  441.   •       -----------                                                         •
  442.   •       This query returns the State Storage manager's recommended CDEV       •
  443.   •          return value.                                                          •
  444.   •                                                                           •
  445.   •       History                                                             •
  446.   •       -------                                                             •
  447.   •                                                                           •
  448.   •       Author          Date            Description                         •
  449.   •       ------------------------------------------------------------------  •
  450.   •       Kevin McEntee   7/25/89         Original Implementation             •
  451.   •                                                                           •
  452.   •                                                                           •
  453.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  454. long Get_State_Storage_Recommended_CDEV_Return_Value(Handle cdevStorage)
  455. {
  456.     long rvalue;
  457.     
  458.     HLock(cdevStorage);
  459.     rvalue = ((State_Storage_Pointer) *cdevStorage)->State_Storage_Recommended_CDEV_Return_Value;
  460.     HUnlock(cdevStorage);
  461.     
  462.     return(rvalue);
  463. }
  464.  
  465.  
  466.  
  467. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  468.   •                                                                           •
  469.   •   Function Name:      Get_ONFF_Value                                      •
  470.   •   --------------                                                          •
  471.   •                                                                           •
  472.   •       Description                                                         •
  473.   •       -----------                                                         •
  474.   •       This query returns the value of the ONFF resource.                  •
  475.   •                                                                           •
  476.   •       History                                                             •
  477.   •       -------                                                             •
  478.   •                                                                           •
  479.   •       Author          Date            Description                         •
  480.   •       ------------------------------------------------------------------  •
  481.   •       Kevin McEntee   7/20/89         Original Implementation             •
  482.   •                                                                           •
  483.   •                                                                           •
  484.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  485. short Get_ONFF_Value(Handle cdevStorage)
  486. {
  487.     Boolean rvalue;
  488.     
  489.     HLock(cdevStorage);
  490.     rvalue = ((State_Storage_Pointer) *cdevStorage)->ONFF_Value;
  491.     HUnlock(cdevStorage);
  492.  
  493.     return(rvalue);
  494. }
  495.  
  496.  
  497.  
  498. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  499.   •                                                                           •
  500.   •   Function Name:       Set_ONFF_Value                                      •
  501.   •   --------------                                                          •
  502.   •                                                                           •
  503.   •       Description                                                         •
  504.   •       -----------                                                         •
  505.   •       This command sets value of the ONFF resource to the passed value.      •
  506.   •                                                                           •
  507.   •       History                                                             •
  508.   •       -------                                                             •
  509.   •                                                                           •
  510.   •       Author          Date            Description                         •
  511.   •       ------------------------------------------------------------------  •
  512.   •       Kevin McEntee   7/20/89         Original Implementation             •
  513.   •                                                                           •
  514.   •                                                                           •
  515.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  516. void Set_ONFF_Value(Handle cdevStorage, short value)
  517. {
  518.     HLock(cdevStorage);
  519.     ((State_Storage_Pointer) *cdevStorage)->ONFF_Value = value;
  520.     HUnlock(cdevStorage);
  521.     
  522.     Write_State_Resource(cdevStorage);
  523. }    
  524.  
  525.  
  526. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  527.   •                                                                           •
  528.   •   Identifier:     Set_Sludge_Factor                                          •
  529.   •   -----------                                                             •
  530.   •                                                                           •
  531.   •       Description                                                         •
  532.   •       -----------                                                         •
  533.   •       This function sets the SLUDGE factor to the passed value.              •
  534.   •                                                                           •
  535.   •       History                                                             •
  536.   •       -------                                                             •
  537.   •                                                                           •
  538.   •       Author          Date            Description                         •
  539.   •       ------------------------------------------------------------------  •
  540.   •       Kevin McEntee   2/20/90         Original Implementation             •
  541.   •                                                                           •
  542.   •                                                                           •
  543.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  544. void     Set_Sludge_Factor(Handle cdevStorage, int new_value)
  545. {
  546.     HLock(cdevStorage);
  547.     ((State_Storage_Pointer) *cdevStorage)->Sludge_Factor = new_value;
  548.     HUnlock(cdevStorage);
  549.     
  550.     Write_State_Resource(cdevStorage);
  551. }
  552.  
  553.  
  554.  
  555. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  556.   •                                                                           •
  557.   •   Identifier:     Increment_Sludge_Factor                                  •
  558.   •   -----------                                                             •
  559.   •                                                                           •
  560.   •       Description                                                         •
  561.   •       -----------                                                         •
  562.   •       This function increments the SLUDGE factor.                          •
  563.   •                                                                           •
  564.   •       History                                                             •
  565.   •       -------                                                             •
  566.   •                                                                           •
  567.   •       Author          Date            Description                         •
  568.   •       ------------------------------------------------------------------  •
  569.   •       Kevin McEntee   2/20/90         Original Implementation             •
  570.   •                                                                           •
  571.   •                                                                           •
  572.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  573. void    Increment_Sludge_Factor(Handle cdevStorage)
  574. {
  575.     HLock(cdevStorage);
  576.     if (((State_Storage_Pointer) *cdevStorage)->Sludge_Factor < 999)
  577.         ((State_Storage_Pointer) *cdevStorage)->Sludge_Factor++;
  578.     HUnlock(cdevStorage);
  579.     
  580.     Write_State_Resource(cdevStorage);
  581. }
  582.  
  583. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  584.   •                                                                           •
  585.   •   Identifier:     Decrement_Sludge_Factor                                  •
  586.   •   -----------                                                             •
  587.   •                                                                           •
  588.   •       Description                                                         •
  589.   •       -----------                                                         •
  590.   •       This function decrements the SLUDGE factor.                          •
  591.   •                                                                           •
  592.   •       History                                                             •
  593.   •       -------                                                             •
  594.   •                                                                           •
  595.   •       Author          Date            Description                         •
  596.   •       ------------------------------------------------------------------  •
  597.   •       Kevin McEntee   2/20/90         Original Implementation             •
  598.   •                                                                           •
  599.   •                                                                           •
  600.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  601. void    Decrement_Sludge_Factor(Handle cdevStorage)
  602. {
  603.     HLock(cdevStorage);
  604.     if (((State_Storage_Pointer) *cdevStorage)->Sludge_Factor > 0)
  605.         ((State_Storage_Pointer) *cdevStorage)->Sludge_Factor--;
  606.     HUnlock(cdevStorage);
  607.     
  608.     Write_State_Resource(cdevStorage);
  609. }
  610.  
  611. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  612.   •                                                                           •
  613.   •   Identifier:     Get_Sludge_Factor                                          •
  614.   •   -----------                                                             •
  615.   •                                                                           •
  616.   •       Description                                                         •
  617.   •       -----------                                                         •
  618.   •       This function returns the SLUDGE factor.                              •
  619.   •                                                                           •
  620.   •       History                                                             •
  621.   •       -------                                                             •
  622.   •                                                                           •
  623.   •       Author          Date            Description                         •
  624.   •       ------------------------------------------------------------------  •
  625.   •       Kevin McEntee   2/20/90         Original Implementation             •
  626.   •                                                                           •
  627.   •                                                                           •
  628.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  629. long    Get_Sludge_Factor(Handle cdevStorage)
  630. {
  631.     long rvalue;
  632.     
  633.     HLock(cdevStorage);
  634.     rvalue = ((State_Storage_Pointer) *cdevStorage)->Sludge_Factor;
  635.     HUnlock(cdevStorage);
  636.     
  637.     return(rvalue);
  638.     
  639. }
  640.  
  641.  
  642. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  643.   •                                                                           •
  644.   •   Identifier:          Set_About_Box_State                                 •
  645.   •   -----------                                                             •
  646.   •                                                                           •
  647.   •       Description                                                         •
  648.   •       -----------                                                         •
  649.   •       This function sets the about box state to true.                      •
  650.   •                                                                           •
  651.   •       History                                                             •
  652.   •       -------                                                             •
  653.   •                                                                           •
  654.   •       Author          Date            Description                         •
  655.   •       ------------------------------------------------------------------  •
  656.   •       Kevin McEntee   2/20/90         Original Implementation             •
  657.   •                                                                           •
  658.   •                                                                           •
  659.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  660. void     Set_About_Box_State(Handle cdevStorage)
  661. {
  662.     HLock(cdevStorage);
  663.     ((State_Storage_Pointer) *cdevStorage)->About_Box_State = true;
  664.     HUnlock(cdevStorage);
  665.     
  666.     Write_State_Resource(cdevStorage);
  667. }
  668.  
  669. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  670.   •                                                                           •
  671.   •   Identifier:          Clear_About_Box_State                               •
  672.   •   -----------                                                             •
  673.   •                                                                           •
  674.   •       Description                                                         •
  675.   •       -----------                                                         •
  676.   •       This function sets the about box state to false.                      •
  677.   •                                                                           •
  678.   •       History                                                             •
  679.   •       -------                                                             •
  680.   •                                                                           •
  681.   •       Author          Date            Description                         •
  682.   •       ------------------------------------------------------------------  •
  683.   •       Kevin McEntee   2/20/90         Original Implementation             •
  684.   •                                                                           •
  685.   •                                                                           •
  686.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  687. void     Clear_About_Box_State(Handle cdevStorage)
  688. {
  689.     HLock(cdevStorage);
  690.     ((State_Storage_Pointer) *cdevStorage)->About_Box_State = false;
  691.     HUnlock(cdevStorage);
  692.     
  693.     Write_State_Resource(cdevStorage);
  694. }
  695.  
  696. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  697.   •                                                                           •
  698.   •   Identifier:          In_About_Box_State                                  •
  699.   •   -----------                                                             •
  700.   •                                                                           •
  701.   •       Description                                                         •
  702.   •       -----------                                                         •
  703.   •       This returns true if the cdev is in the about box state, false      •
  704.   •          otherwise.                                                          •
  705.   •                                                                           •
  706.   •       History                                                             •
  707.   •       -------                                                             •
  708.   •                                                                           •
  709.   •       Author          Date            Description                         •
  710.   •       ------------------------------------------------------------------  •
  711.   •       Kevin McEntee   2/20/90         Original Implementation             •
  712.   •                                                                           •
  713.   •                                                                           •
  714.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  715. Boolean In_About_Box_State(Handle cdevStorage)
  716. {
  717.     Boolean rvalue;
  718.     
  719.     HLock(cdevStorage);
  720.     rvalue = ((State_Storage_Pointer) *cdevStorage)->About_Box_State;
  721.     HUnlock(cdevStorage);
  722.     
  723.     return(rvalue);
  724. }
  725.  
  726.  
  727.  
  728. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  729.   •                                                                           •
  730.   •   Identifier:      Set_Original_A_TRAP_Exception_Vector_Value              •
  731.   •   -----------                                                             •
  732.   •                                                                           •
  733.   •       Description                                                         •
  734.   •       -----------                                                         •
  735.   •       This function saves the value for the original a-trap exception     •
  736.   •          vector.                                                              •
  737.   •                                                                           •
  738.   •       History                                                             •
  739.   •       -------                                                             •
  740.   •                                                                           •
  741.   •       Author          Date            Description                         •
  742.   •       ------------------------------------------------------------------  •
  743.   •       Kevin McEntee   2/20/90         Original Implementation             •
  744.   •                                                                           •
  745.   •                                                                           •
  746.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  747. void     Set_Original_A_TRAP_Exception_Vector_Value(Handle cdevStorage, Ptr value)
  748. {
  749.     HLock(cdevStorage);
  750.     ((State_Storage_Pointer) *cdevStorage)->Original_A_TRAP_Exception_Vector_Value = value;
  751.     HUnlock(cdevStorage);
  752.     
  753.     Write_State_Resource(cdevStorage);
  754. }
  755.  
  756. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  757.   •                                                                           •
  758.   •   Identifier:      Get_Original_A_TRAP_Exception_Vector_Value              •
  759.   •   -----------                                                             •
  760.   •                                                                           •
  761.   •       Description                                                         •
  762.   •       -----------                                                         •
  763.   •       This function returns the value for the saved a-trap exception      •
  764.   •          vector.                                                              •
  765.   •                                                                           •
  766.   •       History                                                             •
  767.   •       -------                                                             •
  768.   •                                                                           •
  769.   •       Author          Date            Description                         •
  770.   •       ------------------------------------------------------------------  •
  771.   •       Kevin McEntee   2/20/90         Original Implementation             •
  772.   •                                                                           •
  773.   •                                                                           •
  774.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  775. Ptr     Get_Original_A_TRAP_Exception_Vector_Value(Handle cdevStorage)
  776. {
  777.     Ptr rvalue;
  778.     
  779.     HLock(cdevStorage);
  780.     rvalue = ((State_Storage_Pointer) *cdevStorage)->Original_A_TRAP_Exception_Vector_Value;
  781.     HUnlock(cdevStorage);
  782.     
  783.     return(rvalue);
  784. }
  785.  
  786. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  787.   •                                                                           •
  788.   •   Identifier:      Set_Original_JUMP_TRACE_Exception_Vector_Value          •
  789.   •   -----------                                                             •
  790.   •                                                                           •
  791.   •       Description                                                         •
  792.   •       -----------                                                         •
  793.   •       This function saves the value for the original a-jump_trace           •
  794.   •          exception vector.                                                      •
  795.   •                                                                           •
  796.   •       History                                                             •
  797.   •       -------                                                             •
  798.   •                                                                           •
  799.   •       Author          Date            Description                         •
  800.   •       ------------------------------------------------------------------  •
  801.   •       Kevin McEntee   2/20/90         Original Implementation             •
  802.   •                                                                           •
  803.   •                                                                           •
  804.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  805. void     Set_Original_JUMP_TRACE_Exception_Vector_Value(Handle cdevStorage, Ptr value)
  806. {
  807.     HLock(cdevStorage);
  808.     ((State_Storage_Pointer) *cdevStorage)->Original_JUMP_TRACE_Exception_Vector_Value = value;
  809.     HUnlock(cdevStorage);
  810.     
  811.     Write_State_Resource(cdevStorage);
  812. }
  813.  
  814. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  815.   •                                                                           •
  816.   •   Identifier:      Get_Original_JUMP_TRACE_Exception_Vector_Value          •
  817.   •   -----------                                                             •
  818.   •                                                                           •
  819.   •       Description                                                         •
  820.   •       -----------                                                         •
  821.   •       This function returns the value for the saved jump_trace exception  •
  822.   •          vector.                                                              •
  823.   •                                                                           •
  824.   •       History                                                             •
  825.   •       -------                                                             •
  826.   •                                                                           •
  827.   •       Author          Date            Description                         •
  828.   •       ------------------------------------------------------------------  •
  829.   •       Kevin McEntee   2/20/90         Original Implementation             •
  830.   •                                                                           •
  831.   •                                                                           •
  832.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  833. Ptr     Get_Original_JUMP_TRACE_Exception_Vector_Value(Handle cdevStorage)
  834. {
  835.     Ptr rvalue;
  836.     
  837.     HLock(cdevStorage);
  838.     rvalue = ((State_Storage_Pointer) *cdevStorage)->Original_JUMP_TRACE_Exception_Vector_Value;
  839.     HUnlock(cdevStorage);
  840.     
  841.     return(rvalue);
  842. }
  843.  
  844. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  845.   •                                                                           •
  846.   •   Identifier:      Set_Location_Of_Parasite_Resource                          •
  847.   •   -----------                                                             •
  848.   •                                                                           •
  849.   •       Description                                                         •
  850.   •       -----------                                                         •
  851.   •       This function saves the location of the parasite resource.          •
  852.   •                                                                           •
  853.   •       History                                                             •
  854.   •       -------                                                             •
  855.   •                                                                           •
  856.   •       Author          Date            Description                         •
  857.   •       ------------------------------------------------------------------  •
  858.   •       Kevin McEntee   2/20/90         Original Implementation             •
  859.   •                                                                           •
  860.   •                                                                           •
  861.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  862. void     Set_Location_Of_Parasite_Resource(Handle cdevStorage, Handle value)
  863. {
  864.     HLock(cdevStorage);
  865.     ((State_Storage_Pointer) *cdevStorage)->Location_Of_Parasite_Resource = value;
  866.     HUnlock(cdevStorage);
  867.     
  868.     Write_State_Resource(cdevStorage);
  869. }
  870.  
  871. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  872.   •                                                                           •
  873.   •   Identifier:      Get_Location_Of_Parasite_Resource                          •
  874.   •   -----------                                                             •
  875.   •                                                                           •
  876.   •       Description                                                         •
  877.   •       -----------                                                         •
  878.   •       This function returns the value for the saved jump_trace exception  •
  879.   •          vector.                                                              •
  880.   •                                                                           •
  881.   •       History                                                             •
  882.   •       -------                                                             •
  883.   •                                                                           •
  884.   •       Author          Date            Description                         •
  885.   •       ------------------------------------------------------------------  •
  886.   •       Kevin McEntee   2/20/90         Original Implementation             •
  887.   •                                                                           •
  888.   •                                                                           •
  889.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  890. Handle     Get_Location_Of_Parasite_Resource(Handle cdevStorage)
  891. {
  892.     Handle rvalue;
  893.     
  894.     HLock(cdevStorage);
  895.     rvalue = ((State_Storage_Pointer) *cdevStorage)->Location_Of_Parasite_Resource;
  896.     HUnlock(cdevStorage);
  897.     
  898.     return(rvalue);
  899. }
  900.  
  901.